package jb;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Location{
    double[] xs;
    double[] ys;
    public Location(String[] strings){
        int len=strings.length;
        xs=new double[len/2];
        ys=new double[len/2];
        for (int i = 0; i < len/2; i++) {
            xs[i]=Double.valueOf(strings[i]);
            ys[i]=Double.valueOf(strings[i+len/2]);
        }
    }
    @Override
    public boolean equals(Object obj) {
        if(obj instanceof Location){
            Location location=(Location)obj;
            return Arrays.equals(location.xs, this.xs) && Arrays.equals(location.ys, this.ys);
        }
        return false;
    }
    @Override
    public int hashCode(){
        return Arrays.hashCode(xs)+Arrays.hashCode(ys);
    }
    @Override
    public String toString(){
        StringBuilder sb=new StringBuilder();
        sb.append("[");
        for (double x : xs) {
            sb.append(x).append(",");
        }
        sb.deleteCharAt(sb.length()-1).append(";");
        for (double y : ys) {
            sb.append(y).append(",");
        }
        sb.deleteCharAt(sb.length()-1).append("]");
        return sb.toString();
    }
}
public class LocationCount {
    public static void main(String[] args) throws FileNotFoundException {
//        File datas=new File("C:\\Users\\lingfengsan\\Desktop\\data.txt");
        File datas=new File("E:\\data.txt");
        Scanner sc=new Scanner(datas);
        HashMap<Location,Integer> hm = new HashMap<>();
        while (sc.hasNext()){
            String str=sc.nextLine();
            String[] strings=str.substring(1,str.length()-1).split(",|;");
            Location location=new Location(strings);
//            hm.compute()
            if(hm.containsKey(location)){
                hm.put(location,hm.get(location)+1);
            }else {
                hm.put(location,1);
            }
        }
        for (Map.Entry<Location, Integer> locationIntegerEntry : hm.entrySet()) {
            System.out.println( locationIntegerEntry.getKey());
            System.out.println("count is "+locationIntegerEntry.getValue());
        }
    }
}
